//
//  Category.m
//  Regatta Mapping
//
//  Created by Asif on 8/11/12.
//  Copyright (c) 2012 TopOfStack Software. All rights reserved.
//

#import "Category.h"

@implementation Category

@synthesize vCont2, mapSegment;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    
    [self setContentSizeForViewInPopover:CGSizeMake(320, 100)];
    
    mapSegment.selectedSegmentIndex = [[NSUserDefaults standardUserDefaults] integerForKey:@"MapType"];
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

-(IBAction)toggleMapType
{
    switch (mapSegment.selectedSegmentIndex) 
    {
        case 0:
        {
            
            [[NSUserDefaults standardUserDefaults] setInteger:mapSegment.selectedSegmentIndex forKey:@"MapType"];
            [vCont2 updateMap:MKMapTypeHybrid];
            
            break;
        }
        case 1:
        {
           
            [[NSUserDefaults standardUserDefaults] setInteger:mapSegment.selectedSegmentIndex forKey:@"MapType"];
            [vCont2 updateMap:MKMapTypeSatellite];
            
            break;
        }
        case 2:
        {
            
            [[NSUserDefaults standardUserDefaults] setInteger:mapSegment.selectedSegmentIndex forKey:@"MapType"];
            [vCont2 updateMap:MKMapTypeStandard];
            
            
            break;
        }
        
        default:
            break;
    }
}

- (void) dealloc
{
    [mapSegment release];
    [vCont2 release];
    [super dealloc];
}

@end
